Skip to main content

Improper Integrals & Numerical Integration Methods

Improper Integrals

Improper integrals are integrals with either infinite limits or discontinuous integrands. They help extend the concept of integration beyond the traditional bounds. Here's how they are defined and evaluated:

Infinite Limits

  • Integral from a to infinity:

    af(x)dx=limtatf(x)dx\int_{a}^{\infty} f(x) \, dx = \lim_{{t \to \infty}} \int_{a}^{t} f(x) \, dx

  • Integral from negative infinity to b:

    bf(x)dx=limttbf(x)dx\int_{-\infty}^{b} f(x) \, dx = \lim_{{t \to -\infty}} \int_{t}^{b} f(x) \, dx

  • Integral from negative infinity to infinity:

    f(x)dx=cf(x)dx+cf(x)dx(provided both integrals are convergent)\int_{-\infty}^{\infty} f(x) \, dx = \int_{-\infty}^{c} f(x) \, dx + \int_{c}^{\infty} f(x) \, dx \quad \text{(provided both integrals are convergent)}

Discontinuous Integrand

  • Discontinuity at a:

    abf(x)dx=limta+tbf(x)dx\int_{a}^{b} f(x) \, dx = \lim_{{t \to a^{+}}} \int_{t}^{b} f(x) \, dx

  • Discontinuity at b:

    abf(x)dx=limtbatf(x)dx\int_{a}^{b} f(x) \, dx = \lim_{{t \to b^{-}}} \int_{a}^{t} f(x) \, dx

  • Discontinuity within the interval (a < c < b):

    abf(x)dx=acf(x)dx+cbf(x)dx(provided both are convergent)\int_{a}^{b} f(x) \, dx = \int_{a}^{c} f(x) \, dx + \int_{c}^{b} f(x) \, dx \quad \text{(provided both are convergent)}

Comparison Test for Improper Integrals

  • If f(x)f(x) is convergent and g(x)f(x)0g(x) \geq f(x) \geq 0 over [a,)[a, \infty), then g(x)g(x) is also convergent.
  • Conversely, if g(x)g(x) is divergent and g(x)f(x)0g(x) \geq f(x) \geq 0 over [a,)[a, \infty), then f(x)f(x) is also divergent.

Useful Fact

For p>0p > 0, the integral a1xpdx\int_{a}^{\infty} \frac{1}{x^p} \, dx converges if p>1p > 1 and diverges for p1p \leq 1.

Numerical Integration Methods

Numerical integration methods are used to approximate the value of a definite integral when it is difficult or impossible to calculate it analytically. The following are common numerical integration rules:

Midpoint Rule

The Midpoint Rule estimates the integral of a function by summing the value of the function at the midpoint of each interval, multiplied by the width of the intervals.

For nn subintervals, the approximation is:

abf(x)dxΔx[f(x1)+f(x2)++f(xn)]\int_{a}^{b} f(x) dx \approx \Delta x \left[ f\left(x_1^*\right) + f\left(x_2^*\right) + \ldots + f\left(x_n^*\right) \right]

where Δx=ban\Delta x = \frac{b - a}{n} and xix_i^* is the midpoint of the ii-th subinterval.

Trapezoid Rule

The Trapezoid Rule calculates the integral by averaging the function values at the endpoints of each interval, effectively estimating the area under the curve using trapezoids.

The formula is:

abf(x)dxΔx2[f(x0)+2f(x1)+2f(x2)++2f(xn1)+f(xn)]\int_{a}^{b} f(x) dx \approx \frac{\Delta x}{2} \left[ f(x_0) + 2f(x_1) + 2f(x_2) + \ldots + 2f(x_{n-1}) + f(x_n) \right]

Simpson's Rule

Simpson's Rule is a more accurate method that uses parabolic arcs to approximate the function between each pair of points. It requires the number of subintervals nn to be even.

The approximation given by Simpson's Rule is:

abf(x)dxΔx3[f(x0)+4f(x1)+2f(x2)++4f(xn1)+f(xn)]\int_{a}^{b} f(x) dx \approx \frac{\Delta x}{3} \left[ f(x_0) + 4f(x_1) + 2f(x_2) + \ldots + 4f(x_{n-1}) + f(x_n) \right]

Practical Use

These rules are particularly useful in Computer Science for solving problems that require numerical solutions, such as in simulations, optimization problems, and areas where the function cannot be integrated symbolically.

Implementation

Here are Python functions that implement each of these rules:

import numpy as np

def midpoint_rule(f, a, b, n):
dx = (b - a) / n
x_mid = np.linspace(a + dx/2, b - dx/2, n)
return np.sum(f(x_mid)) * dx

def trapezoid_rule(f, a, b, n):
dx = (b - a) / n
x = np.linspace(a, b, n + 1)
return dx/2 * np.sum(f(x[:-1]) + f(x[1:]))

def simpsons_rule(f, a, b, n):
if n % 2 == 1:
raise ValueError("n must be even for Simpson's Rule")
dx = (b - a) / n
x = np.linspace(a, b, n + 1)
y = f(x)
return dx/3 * np.sum(y[0:-1:2] + 4*y[1::2] + y[2::2])

Notes:

  • f is the integrand function.
  • a and b are the limits of integration.
  • n is the number of subintervals.
  • dx is the width of each subinterval.
  • For simpsons_rule, an even number of subintervals is necessary.